package com.efast.dmom.mes.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.efast.dmom.mes.bean.QualityProductDefect;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.datahandlers.entity.QualityProductDefectHandler;
import com.efast.dmom.mes.service.QualityProductDefectService;
@Service
public class QualityProductDefectServiceImpl implements QualityProductDefectService {
//	("qualityProductDefectServiceimpl")
	@Autowired
	private QualityProductDefectHandler qualityProductDefectHandler;
	
	private ResultBean setErrorMessage(String message) {
		ResultBean resultBean = new ResultBean(false);
		resultBean.setMessage(message);
		return resultBean;
	}
	@Override
	public ResultBean save(QualityProductDefect entity) {
		if (entity.getInnerData() == null) {
			return setErrorMessage("Entity is null");
		}
		ResultBean save = qualityProductDefectHandler.save(entity);
		return save;
	}

	@Override
	public ResultBean delete(QualityProductDefect entity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ResultBean update(QualityProductDefect entity) {
		if (entity.getInnerData() == null) {
			return setErrorMessage("Entity is null");
		}
		ResultBean update = qualityProductDefectHandler.update(entity);
		return update;
	}

	@Override
	public QualityProductDefect getById(long id) {
		QualityProductDefect byId = qualityProductDefectHandler.getById(id);
		return byId;
	}

	@Override
	public QualityProductDefect getByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public ResultBean batchDelete(List<QualityProductDefect> list) {
		if (list.size() == 0) {
			return setErrorMessage("select is null");
		}
		ResultBean batchDelete = qualityProductDefectHandler.deleteBatch(list);
		return batchDelete;
	}
	@Override
	public ResultBean save(List<QualityProductDefect> list) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public ResultBean update(List<QualityProductDefect> list) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public ResultBean delete(List<QualityProductDefect> list) {
		// TODO Auto-generated method stub
		return null;
	}

}
